package com.unicom.scg.scancodego.service.impl;

import com.unicom.scg.scancodego.entity.*;
import com.unicom.scg.scancodego.mapper.TAddressMapper;
import com.unicom.scg.scancodego.mapper.TOrderMapper;
import com.unicom.scg.scancodego.mapper.TProductMapper;
import com.unicom.scg.scancodego.service.TorderService;
import com.unicom.scg.scancodego.vo.PostFormGusetVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liyy22
 * @version 1.0
 * @date 2019/11/2 16:33
 */
@Service
public class TorderServiceimpl implements TorderService {


    @Autowired
    TOrderMapper tOrderMapper;
    @Autowired
    TProductMapper tProductMapper;
    @Override
    public List<TOrder> getOrderBytResident_id(String resident_id) {
        TOrderExample tOrderExample = new TOrderExample();
        //example.createCriteria().andPositionEqualTo();
        tOrderExample.createCriteria().andResidentIdEqualTo(resident_id);
        List<TOrder> tOrders = tOrderMapper.selectByExample(tOrderExample);
        return tOrders;
    }

    @Override
    public TProduct selectById(Integer productId) {
        TProduct tProduct = tProductMapper.selectByPrimaryKey(productId);
        return tProduct;
    }


    @Override
    public void saveOrder(PostFormGusetVo postFormGusetVo) {
        TOrder tOrder = new TOrder();
        tOrder.setAddr8Id(postFormGusetVo.getAddr8_id());
        tOrder.setCustName(postFormGusetVo.getCustname());
        tOrder.setContactsName(postFormGusetVo.getContacts_name());
        tOrder.setContactsPhone(postFormGusetVo.getContacts_phone());
        tOrder.setProductId(postFormGusetVo.getProduct_id());
        tOrder.setResidentId(postFormGusetVo.getResident_id());
        tOrder.setResidentImgFace(postFormGusetVo.getImg_face());
        tOrder.setResidentImgBack(postFormGusetVo.getImg_back());
        tOrderMapper.insertSelective(tOrder);

    }
}
